function formatScheduleRule (rule, cb) {
  const defaultScheduleRule = {
    second: null,
    minute: null,
    hour: null,
    date: null,
    year: null,
    dayOfWeek: null
  }
  let formatRule = null
  if (rule) {
    formatRule = Object.assign(rule)
    // 转换 dayOfWeek 空数组的情况、会造成生成 nodeSchedule 示例卡死
    if (Array.isArray(formatRule.dayOfWeek) && formatRule.dayOfWeek.length === 0) {
      formatRule.dayOfWeek = null
    }
  }
  Object.keys(formatRule).forEach(key => {
    if (formatRule[key] === null) delete formatRule[key]
  })
  return formatRule || Object.assign(defaultScheduleRule)
}

module.exports = {
  formatScheduleRule
}
